package com.mz.ozy.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.FriendBean;
import com.mz.ozy.bean.MyBounsBean;
import com.mz.ozy.bean.MyBounsRecodeBean;
import com.mz.ozy.bean.NewBonusBean;
import com.mz.ozy.bean.NewBonusDetailBean;
import com.mz.ozy.bean.NewBonusDonateBean;
import com.mz.ozy.bean.NewGQBean;
import com.mz.ozy.bean.NewResponeBean;
import com.mz.ozy.bean.PronotionBean;
import com.mz.ozy.mvp.presenter.MyBounsPresenter;
import com.mz.ozy.mvp.view.MyBonusContract;
import com.mz.ozy.utils.StringUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author liucan on 2020/4/1 0001.
 */
public class MyBonusActivity extends BaseActivity<MyBonusContract.View, MyBounsPresenter> implements MyBonusContract.View {
    @BindView(R.id.ll_top)
    LinearLayout llTop;
    @BindView(R.id.tv_balance)
    TextView tvBalance;
    @BindView(R.id.tv_online_state)
    TextView tvOnlineState;
//    @BindView(R.id.tv_lj_score)
//    TextView tvLjScore;
    @BindView(R.id.tv_grade)
    TextView tvGrade;
    @BindView(R.id.tv_jxs)
    TextView tvJxs;
    @BindView(R.id.tv_tj)
    TextView tvTj;
    @BindView(R.id.tv_small_team)
    TextView tvSmallTeam;
    @BindView(R.id.tv_balance_team)
    TextView tvBalanceTeam;

//    @BindView(R.id.tv_health_speak)
//    TextView tvHealthSpeak;
//    @BindView(R.id.tv_team_bv)
//    TextView tvTeamBv;
//    @BindView(R.id.tv_last_month)
//    TextView tvLastMonth;
//    @BindView(R.id.tv_wait_money)
//    TextView tvWaitMoney;
//    @BindView(R.id.tv_wait_score)
//    TextView tvWaitScore;
//    @BindView(R.id.tv_now_grade)
//    TextView tvNowGrade;
//    @BindView(R.id.tv_wait_money_now)
//    TextView tvWaitMoneyNow;
//    @BindView(R.id.tv_wait_score_now)
//    TextView tvWaitScoreNow;
//    @BindView(R.id.ll_root)
//    LinearLayout llRoot;
    @BindView(R.id.tv_fu)
    TextView tvFu;
    @BindView(R.id.tv_tx_money)
    TextView tvTxMoney;
    @BindView(R.id.bnt_donate)
    Button tvDonate;
    @BindView(R.id.tv_lj_bonus)
    TextView tvLjBonus;

//    private FriendBean data;
//    private PronotionBean dataItem;

    private NewBonusBean mBonusBean;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_bouns);
        ButterKnife.bind(this);
        initTitle2();
//        llRoot.setBackgroundColor(0);
        llTop.setBackgroundColor(0);
        tvCenterTitle.setText("我的积分");
        tvBack.setImageResource(R.mipmap.white_back);
        tvCenterTitle.setTextColor(getResources().getColor(R.color.white));
//        rightTextView.setTextSize(10);
//        rightTextView.setGravity(Gravity.CENTER);
//        rightTextView.setTextColor(getResources().getColor(R.color.white));
//        rightTextView.setVisibility(View.VISIBLE);
//        rightTextView.setText("奖励明细");
//        rightTextView.setBackgroundResource(R.drawable.round_89c03b);
//        rightTextView.setHeight(65);
//        rightTextView.setWidth(160);

        rightTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyBonusDetailActivity.go(MyBonusActivity.this, 1, mBonusBean.remain);
            }
        });
//        mPresenter.info(this, 0);
//        mPresenter.vipUpDataSh(this, "", 0);
//        mPresenter.vipUpSh(this, 0);
        mPresenter.newBonus(this);
    }

    @Override
    public void newBonusSuccess(NewBonusBean bean) {
        mBonusBean = bean;

        tvBalance.setText(mBonusBean.remain);
        tvLjBonus.setText(mBonusBean.amount);
        tvTxMoney.setText(mBonusBean.withdraw);

        tvTj.setText(mBonusBean.exp1 + "");
        tvSmallTeam.setText(mBonusBean.exp2 + "");

        tvBalanceTeam.setText(mBonusBean.team);
    }


    //    @Override
    public void getInfoSuccess(MyBounsBean bean) {

//        if (bean.getStating() == 1 && !TextUtils.isEmpty(bean.getWenan())) {
//            tvOnlineState.setVisibility(View.VISIBLE);
//            tvOnlineState.setText(bean.getWenan());
//        } else {
//            tvOnlineState.setVisibility(View.GONE);
//        }
//
//        tvLjBonus.setText(StringUtils.changeSN(bean.getTotal_bonus(), 2));
//        tvTxMoney.setText( StringUtils.changeSN(bean.getTxBonus(), 2));
//        tv_lj_score.setText(StringUtils.changeSN(bean.getBonusBalance(), 2));

//        String grade_state = "";
//        switch (bean.getGrade_state()) {
//
//            case 0:
//                grade_state = "在职";
//                break;
//            case 1:
//                grade_state = "休职";
//                break;
//            case 2:
//                grade_state = "停职";
//                break;
//            case 3:
//                grade_state = "离职";
//                break;
//        }
//
//        tvTj.setText(bean.getZtnum());
//        tvHealthSpeak.setText(bean.getOne_seven_num() + "(" + "在职" + bean.getZz_one_seven_num() + ")");
//        tvTeamBv.setText(StringUtils.changeSN(bean.getTotal_bv(), 2));
//        if (bean.getState().equals("0")) {
//            tvLastMonth.setText("待发放");
//        } else {
//            tvLastMonth.setText("已发放");
//        }

//        if (bean.getDistributor() == 0) {
//            tvJxs.setVisibility(View.GONE);
//        }
//        if (bean.getServies_dot() == 0) {
//            tvFu.setVisibility(View.GONE);
//        }
//        switch (bean.getDistributor()) {
//            case 1:
//                tvJxs.setText("一级经销商");
//                break;
//            case 2:
//                tvJxs.setText("二级经销商");
//                break;
//            case 3:
//                tvJxs.setText("三级经销商");
//                break;
//            case 4:
//                tvJxs.setText("四级经销商");
//                break;
//            case 5:
//                tvJxs.setText("五级经销商");
//                break;
//
//
//        }
//
//
//        switch (bean.getServies_dot()) {
//            case 1:
//                tvFu.setText("社区服务网点");
//                break;
//            case 2:
//                tvFu.setText("区级服务网点");
//                break;
//            case 3:
//                tvFu.setText("市级服务网点");
//                break;
//            case 4:
//                tvFu.setText("地区级服务网点");
//                break;
//
//
//        }
//
//
//
////        tvLjScore.setText(StringUtils.changeSN(bean.getTotal_integral(), 2));
////        tvWaitMoney.setText(StringUtils.changeSN(bean.getBonus_profit(), 2));
////        tvWaitScore.setText(StringUtils.changeSN(bean.getIntegral_profit(), 2));
//
////          tvNowGrade.setText(bean.getTwo_four_num() + "");
////          tvWaitMoneyNow.setText(bean.getBonus_profit());
////          tvWaitScoreNow.setText(bean.getIntegral_profit());
//        tvSmallTeam.setText(bean.getTwo_four_num() + "(" + "在职" + bean.getZz_two_four_num() + ")");
//
//        switch (bean.getGrade()) {
//            case 0:
//                tvGrade.setText("普通会员(" + grade_state + ")");
//                break;
//            case 1:
//                tvGrade.setText("VIP(" + grade_state + ")");
//                break;
//            case 2:
//                tvGrade.setText("金卡VIP(" + grade_state + ")");
//                break;
//            case 3:
//                tvGrade.setText("钻卡VIP(" + grade_state + ")");
//                break;
//            case 4:
//                tvGrade.setText("健康顾问(" + grade_state + ")");
//                break;
//            case 5:
//                tvGrade.setText("资深顾问(" + grade_state + ")");
//                break;
//            case 6:
//                tvGrade.setText("蓝宝顾问(" + grade_state + ")");
//                break;
//            case 7:
//                tvGrade.setText("绿宝顾问(" + grade_state + ")");
//                break;
//            case 8:
//                tvGrade.setText("红宝督导(" + grade_state + ")");
//                break;
//            case 9:
//                tvGrade.setText("蓝钻督导(" + grade_state + ")");
//                break;
//            case 10:
//                tvGrade.setText("绿钻督导(" + grade_state + ")");
//                break;
//            case 11:
//                tvGrade.setText("红钻督导(" + grade_state + ")");
//                break;
//            case 12:
//                tvGrade.setText("黑钻首席(" + grade_state + ")");
//                break;
//        }

    }

    @OnClick({R.id.tv_bonus_detail, R.id.bnt_tx, R.id.bnt_exchange, R.id.bnt_donate, R.id.tv_hand_report})
    public void onViewClicked(View view) {
        switch (view.getId()) {
//            case R.id.tv_level_up:
//                if (mBonusBean != null || dataItem != null || data != null) {
//                    if (mBonusBean.getGrade() == 0 || data.getPromotion_map().getState() == 4) {
//                        UpdataActivity.go(this, data.getPromotion_map().getId(), 0, true);
//                    } else if (data.getPromotion_map().getState() == 2) {
//                        PromotionTypeActivity.go(this, 0);
//                    } else if (data.getPromotion_map().getState() == 1 && dataItem.getIfup() == 1) {
//                        UpdataActivity.go(this, data.getPromotion_map().getId(), 0, true);
//                    } else {
//                        PromotionTypeActivity.go(this, 0);
//                    }
//                }
//                break;

            case R.id.tv_bonus_detail:
                MyBonusDetailActivity.go(this, 1, mBonusBean.remain);
                break;
            case R.id.bnt_tx:
                MeNewWithActivity.go(MyBonusActivity.this, mBonusBean.remain);
//                startActivity(new Intent(MyBonusActivity.this, MeNewWithActivity.class));

                break;
            case R.id.bnt_exchange:
                if (mBonusBean != null) {
                    Intent intent = new Intent(MyBonusActivity.this, ExchangeObActivity.class);
                    intent.putExtra("balance", mBonusBean.remain);
                    startActivity(intent);
                }

                break;
            case R.id.bnt_donate:
                Intent intent = new Intent(MyBonusActivity.this, MyBonusDonateActivity.class);
                startActivity(intent);
                break;

            case R.id.tv_hand_report:
                {
                    Intent tintent = new Intent(MyBonusActivity.this, HandReportActivity.class);
                    startActivity(tintent);
                }
                break;

//            case R.id.tv_level_conf:
//                startActivity(new Intent(MyBonusActivity.this, ApplyMeetActivity.class));
//                break;
        }
    }

    @Override
    public void getInfoRecode(MyBounsRecodeBean bean) {

    }

    @Override
    public void getVipUpShSuccess(FriendBean bean) {
//        data = bean;
    }

    @Override
    public void getVipUpDataInfoSuccess(PronotionBean bean) {
//        dataItem = bean;
    }

    @Override
    public void newBonusDetailSuccess(NewBonusDetailBean bean) {

    }

    @Override
    public void newBonusDonateSuccess(NewBonusDonateBean bean) {

    }

    @Override
    public void newGQSuccess(NewGQBean bean) {

    }
}
